package com.cjh.service.impl;

import com.alibaba.druid.sql.visitor.functions.If;
import com.cjh.dao.UserDao;
import com.cjh.dao.impl.UserDaoImpl;
import com.cjh.pojo.User;
import com.cjh.service.UserService;

/**
 * @Author: huahua
 * @Date: 2020-09-02 22:25
 */
public class UserServiceImpl implements UserService {

   private UserDao userDao = new UserDaoImpl();

    @Override
    public void registerUser(User user) {
        userDao.saveUser(user);
    }

    @Override
    public User login(User user) {
        return userDao.queryUserByUsernameAndPassword(user.getUsername(),user.getPassword());
    }

    @Override
    public boolean existUsername(String username) {
        if (userDao.queryUserByUsername(username)==null){
            //没查到表示可用
            return false;
        }
        return true;
    }
}
